package com.xisoft.devise.controller;

import com.xisoft.common.aspect.AppMonitorRuning;
import com.xisoft.common.pubEnv.LoggerUtil;
import com.xisoft.common.result.Result;
import com.xisoft.devise.service.impl.EngineServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * *
 * Created with Description:
 *
 * @version 1.0 <br>
 * @packagename: com.xisoft.frame.ctrl<br>
 * @author: LiBencheng <br>
 * @computer: licheng <br>
 * @date: Created on 2022/9/7 10:08 <br>
 */
@RestController
@RequestMapping ("engine")
public class EngineCtrl
{
    @Autowired
    EngineServiceImpl engineService;

    @RequestMapping ("/generateConfig")
    @AppMonitorRuning (method = "EngineCtrl.generateConfig", funEffect = "生成表单，列表配置！")
    public Result generateConfig(String json, HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        try
        {
            return Result.ok(engineService.generateConfig(json));
        }
        catch (Exception e)
        {
            LoggerUtil.getInstance().exception("保存元数据并生成SQLScript失败！", e);
            return Result.fail().message(e.getMessage());
        }
    }
}
